//
//  HMNoDataReload.m
//  HMMarket
//
//  Created by haohao on 2017/6/2.
//  Copyright © 2017年 homai. All rights reserved.
//

#import "HMNoDataReload.h"

@implementation HMNoDataReload

- (instancetype)init{
    self = [super init];
    if (self) {
        self.center = [UIApplication sharedApplication].keyWindow.center;
        self.frame = CGRectMake(0, 64, KWidthSCREEN, KHeightSCREEN - 64);
        [self setUpSubview];
    }
    return self;
}


- (void)setUpSubview {
//    UIView *_nodata = [[UIView alloc] init];
//    _nodata.backgroundColor = kBackGolor;
//    _nodata.frame = CGRectMake(0, 64, KWidthSCREEN, KHeightSCREEN - 64);
//    _nodata.hidden = YES;
    
    UIImageView * icon = [[UIImageView alloc] initWithImage:[UIImage imageNamed:@"default_network"]];
    icon.y = 180 * KEYWIDTH;
    icon.centerX =KWidthSCREEN/2;
    [self addSubview:icon];
    
    UILabel * titleLable = [[UILabel alloc] init];
    titleLable.text = @"网络请求失败";
    titleLable.font = [UIFont boldSystemFontOfSize:17];
    titleLable.textColor = kGrayTextColor;
    titleLable.x = 0;
    titleLable.y = icon.y + icon.height + 16;
    titleLable.size = CGSizeMake(KWidthSCREEN, 20);
    titleLable.textAlignment = NSTextAlignmentCenter;
    [self addSubview:titleLable];
    
    UIButton * reuseBtn = [UIButton buttonWithType:UIButtonTypeCustom];
    [reuseBtn setTitle:@"重新加载" forState:UIControlStateNormal];
    [reuseBtn setTitleColor:kffffff forState:UIControlStateNormal];
    reuseBtn.backgroundColor = kMainColor;
    reuseBtn.layer.cornerRadius = 5;
    reuseBtn.layer.masksToBounds = YES;
    reuseBtn.y = CGRectGetMaxY(titleLable.frame) + 13;
    reuseBtn.width = 130;
    reuseBtn.height = 40;
    reuseBtn.centerX = KWidthSCREEN / 2;
    [self addSubview:reuseBtn];
    [reuseBtn addTarget:self action:@selector(refreshData) forControlEvents:UIControlEventTouchUpInside];
    
//    [self addSubview:_nodata];
}

- (void)refreshData {
    _reloadData();
}

/*
// Only override drawRect: if you perform custom drawing.
// An empty implementation adversely affects performance during animation.
- (void)drawRect:(CGRect)rect {
    // Drawing code
}
*/

@end
